//
//  OtherDetailLineCell.swift
//  ImGuider X
//
//  Created by llt on 2018/9/27.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class OtherDetailLineCell: UITableViewCell {

    @IBOutlet weak var headImageView: UIImageView!
    
    @IBOutlet weak var headTitleLabel: UILabel!
    
    @IBOutlet weak var headTitleLabelTop: NSLayoutConstraint!
    @IBOutlet weak var cellbottom: NSLayoutConstraint!
    
    @IBOutlet weak var guiderImageView: UIImageView!
    
    @IBOutlet weak var guiderNameLabel: UILabel!
    @IBOutlet weak var guiderNameLabelTop: NSLayoutConstraint!
    
    @IBOutlet weak var guiderIntroLabel: UILabel!
    
    @IBOutlet weak var nextTagImageView: UIImageView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.backgroundColor = kThemeBgColor
        
        headImageView.layer.cornerRadius = 20
        headImageView.layer.borderColor = kContentColor.cgColor
        headImageView.layer.borderWidth = 0.5
        
        nextTagImageView.addShadow(type: .btn)
    }

    var isLast:Bool = false {
        
        didSet {
            
            cellbottom.constant = isLast ? 40 : 24
        }
    }
    
    var isTitleHidden:Bool = false {
        
        didSet {
            
            headTitleLabel.text = isTitleHidden ? nil : LocalizedString("speech_guide")
            headTitleLabelTop.constant = isTitleHidden ? -24 : 0
        }
    }
    
    var line:Line? {
        
        didSet {
            
            guiderImageView.setImage(string: line?.guide?.headimg, placeholder: UIImage(named: "placeholder_squ")!)
            
            if let type = line?.type, type == .citytour {
                
                guiderNameLabel.text = line?.guide?.realname
                guiderIntroLabel.text = nil
                guiderNameLabelTop.constant = 8
                return
            }
            
            guiderNameLabelTop.constant = 3
            guiderNameLabel.text = line?.linename
            guiderIntroLabel.text = line?.linedesc
        }
    }
    
}
